


public class Test {
    String s;


    public static int add(int a, int b) {
        return a + b;
    }

    public static int add(int a, int b, int c) {
        return a + b + c;
    }

    /*public static int add(int[] array) {
        int ret = 0;
        for (int x : array) {
            ret = x += x;
        }
        return ret;
    }*/


    /**
     * 表示可变参数
     * @param array
     * @return
     */
    public static int add(int... array) {
        int ret = 0;
        for (int x : array) {
            ret += x;
        }
        return ret;
    }


    public static void main(String[] args) {
        int[] array = {1, 2, 3, 4, 5};
        System.out.println(add(array));
        System.out.println(add(new int[]{1, 2, 3, 4, 5, 6, 7, 8}));

        //System.out.println(new int[]{1,2,3,4,5}.add());

    }


    public static void main1(String[] args) {
        /*Test test = new Test();
        System.out.println("s=" + test.s);*/
        // 匿名对象
        System.out.println(new Test().s);
    }
}
